<?php

//启动结算server
error_reporting(0);
date_default_timezone_set('PRC');
$http = new swoole_http_server("0.0.0.0", 8088);

$http->set(array(
    'worker_num' => 5,   //工作进程数量
    'max_request' => 2000,//work进程处理请求数
    'package_max_length'=>20*1024*1024,//20M 最大数据包尺寸字节
    'daemonize' => true //是否作为守护进程
));

define('BASEDIR',__DIR__);

require 'App/Common/Conf/const.php';
require 'vendor/autoload.php';
require 'SasPHP/SasPHP.php';

$http->on('start', function($serv) {
    cli_set_process_title("sd_serve");
});
$http->on('request', function ($request, $response) {
    // 阻止google浏览器的ico请求
    if(strtolower($request->server['request_uri'] == '/favicon.ico')){
        $response->end();return;}

    $_ENV = $response;
    $_SERVER = $request->server;
    $_GET = $request->get;
    $_POST = $request->post;
    $_FILES = property_exists($request,'files') ? $request->files : [];
    $GLOBALS = $request->rawContent();

    $res = SasPHP\SasPHP::start();
    $response->header('Access-Control-Allow-Origin','*');
    $response->header('Content-type','application/json;charset=utf-8');
    $response->end($res);
});

$http->start();